#---------------------------------[知乎：叶枝黎曼]--------------------------
'''
输入：1 2 3 4 5 5 5 6 7 8 9
      5
      
输出：4 5  #第一个数为下标位置，第二个数为值
'''
def isok(x):
    if s[x] >= goal:
        return True
    return False

s = [int(i) for i in input().split()]
goal = int(input())


left = 0
right = len(s) - 1
while left < right:
    mid = left + right >> 1
    if isok(mid):
        right = mid 
    else:
        left = mid + 1

print(left,s[left])
